import { createApp, createVNode } from "vue";
import "./style.css";
import App from "./App.vue";

//引入router
import router from "./router/index";

//引入store
import { store, key } from "./store/index";

//引入ElementPlus
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";

//引入element-puls-icon
import * as ElIcons from "@element-plus/icons-vue";

const app = createApp(App);

app.use(ElementPlus).use(store, key).use(router).mount("#app");

//第一种方式
Object.keys(ElIcons).forEach((key) => {
  app.component(key, ElIcons[key]);
});

//第二种方式
const Icon = (props: { icon: string }) => {
  const { icon } = props;
  return createVNode(ElIcons[icon as keyof typeof ElIcons]);
};
app.component("Icon", Icon);
